using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Recorder;
using UnityEngine.Recorder.Input;

namespace UTJ.FrameCapturer.Recorders
{
	[ExecuteInEditMode]
	public class MP4RecorderSettings : BaseFCRecorderSettings
	{
		public fcAPI.fcMP4Config m_MP4EncoderSettings = fcAPI.fcMP4Config.default_value;

		public bool m_AutoSelectBR;

		public override bool isPlatformSupported => Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer;

		private MP4RecorderSettings()
		{
			m_BaseFileName.pattern = "movie.<ext>";
			m_AutoSelectBR = true;
		}

		public override List<RecorderInputSetting> GetDefaultInputSettings()
		{
			List<RecorderInputSetting> list = new List<RecorderInputSetting>();
			list.Add(NewInputSettingsObj<CBRenderTextureInputSettings>("Pixels"));
			return list;
		}

		public override RecorderInputSetting NewInputSettingsObj(Type type, string title)
		{
			RecorderInputSetting recorderInputSetting = base.NewInputSettingsObj(type, title);
			if (type == typeof(CBRenderTextureInputSettings))
			{
				CBRenderTextureInputSettings cBRenderTextureInputSettings = (CBRenderTextureInputSettings)recorderInputSetting;
				cBRenderTextureInputSettings.m_ForceEvenSize = true;
				cBRenderTextureInputSettings.m_FlipFinalOutput = true;
			}
			return recorderInputSetting;
		}

		public override bool SelfAdjustSettings()
		{
			if (base.inputsSettings.Count == 0)
			{
				return false;
			}
			bool result = false;
			if (base.inputsSettings[0] is ImageInputSettings)
			{
				ImageInputSettings imageInputSettings = (ImageInputSettings)base.inputsSettings[0];
				if (imageInputSettings.maxSupportedSize != EImageDimension.x2160p_4K)
				{
					imageInputSettings.maxSupportedSize = EImageDimension.x2160p_4K;
					result = true;
				}
			}
			return result;
		}
	}
}
